;;; $Id: housekeeping.sld 364 2013-12-05 05:39:18Z alan.watson.f $

(define-library (oaxaca housekeeping)

  (export housekeeping-initialized?
          housekeeping-wait
          housekeeping-cpu-usage
          housekeeping-disk-usage)

  (import (scheme base))

  (import (prefix (oaxaca foreign) foreign:)
          (oaxaca thread))

  (begin

    (define (housekeeping-initialized?)
      (not (zero? (foreign:housekeeping-initialized))))

    (define (check-housekeeping-initialized)
      (unless (housekeeping-initialized?)
        (error "the housekeeping is not initialized."))
      (values))

    (define (housekeeping-wait)
      (thread-wait-until! housekeeping-initialized?)
      (values))

    (define (housekeeping-cpu-usage)
      (check-housekeeping-initialized)
      (foreign:housekeeping-cpu-usage))

    (define (housekeeping-disk-usage)
      (check-housekeeping-initialized)
      (foreign:housekeeping-disk-usage))))
